﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SDS.SPConnectors.SPList.Tests
{
    //[TestClass]
    public class EncodeNmToken
    {
        [TestMethod] public void Simple_EncodeNmToken() { System.Xml.XmlConvert.EncodeNmToken("Simple").Should().Be("Simple"); }
        [TestMethod] public void Space_EncodeNmToken() { System.Xml.XmlConvert.EncodeNmToken("A Phrase").Should().Be("A_x0020_Phrase"); }
        [TestMethod] public void Number_EncodeNmToken() { System.Xml.XmlConvert.EncodeNmToken("Numb3r").Should().Be("Numb3r"); }
        [TestMethod] public void Number2_EncodeNmToken() { System.Xml.XmlConvert.EncodeNmToken("2").Should().Be("2"); }
        [TestMethod] public void Hyphen_EncodeNmToken() { System.Xml.XmlConvert.EncodeNmToken("-").Should().Be("_x002D_"); }
        [TestMethod] public void HyphenatedWord_EncodeNmToken() { System.Xml.XmlConvert.EncodeNmToken("Hyphenated-Word").Should().Be("Hyphenated_x002D_Word"); }
    }
    
    //[TestClass]
    public class EncodeName
    {
        [TestMethod] public void Simple_EncodeName() { System.Xml.XmlConvert.EncodeName("Simple").Should().Be("Simple"); }
        [TestMethod] public void Space_EncodeName() { System.Xml.XmlConvert.EncodeName("A Phrase").Should().Be("A_x0020_Phrase"); }
        [TestMethod] public void Number_EncodeName() { System.Xml.XmlConvert.EncodeName("Numb3r").Should().Be("Numb3r"); }
        [TestMethod] public void Number2_EncodeName() { System.Xml.XmlConvert.EncodeName("2").Should().Be("2"); }
        [TestMethod] public void Hyphen_EncodeName() { System.Xml.XmlConvert.EncodeName("-").Should().Be("_x002D_"); }
        [TestMethod] public void HyphenatedWord_EncodeName() { System.Xml.XmlConvert.EncodeName("Hyphenated-Word").Should().Be("Hyphenated_x002D_Word"); }
    }

    //[TestClass]
    public class EncodeLocalName
    {
        [TestMethod] public void Simple_EncodeLocalName() { System.Xml.XmlConvert.EncodeLocalName("Simple").Should().Be("Simple"); }
        [TestMethod] public void Space_EncodeLocalName() { System.Xml.XmlConvert.EncodeLocalName("A Phrase").Should().Be("A_x0020_Phrase"); }
        [TestMethod] public void Number_EncodeLocalName() { System.Xml.XmlConvert.EncodeLocalName("Numb3r").Should().Be("Numb3r"); }
        [TestMethod] public void Number2_EncodeLocalName() { System.Xml.XmlConvert.EncodeLocalName("2").Should().Be("2"); }
        [TestMethod] public void Hyphen_EncodeLocalName() { System.Xml.XmlConvert.EncodeLocalName("-").Should().Be("_x002D_"); }
        [TestMethod] public void HyphenatedWord_EncodeLocalName() { System.Xml.XmlConvert.EncodeLocalName("Hyphenated-Word").Should().Be("Hyphenated_x002D_Word"); }
    }

    [TestClass]
    public class StaticNameEncode
    {
        [TestMethod] public void Simple_StaticNameEncode() { SPListConnector.StaticNameEncode("Simple").Should().Be("Simple"); }
        [TestMethod] public void Space_StaticNameEncode() { SPListConnector.StaticNameEncode("A Phrase").Should().Be("A_x0020_Phrase"); }
        [TestMethod] public void Number_StaticNameEncode() { SPListConnector.StaticNameEncode("Numb3r").Should().Be("Numb3r"); }
        [TestMethod] public void Number2_StaticNameEncode() { SPListConnector.StaticNameEncode("2").Should().Be("2"); }
        [TestMethod] public void Hyphen_StaticNameEncode() { SPListConnector.StaticNameEncode("-").Should().Be("_x002d_"); }
        [TestMethod] public void HyphenatedWord_StaticNameEncode() { SPListConnector.StaticNameEncode("Hyphenated-Word").Should().Be("Hyphenated_x002d_Word"); }
        [TestMethod] public void Underscore_StaticNameEncode() { SPListConnector.StaticNameEncode("Under_Score").Should().Be("Under_Score"); }
        [TestMethod] public void FakeHex_StaticNameEncode() { SPListConnector.StaticNameEncode("Fake_x0020_Hex").Should().Be("Fake_x0020_Hex"); }

        [TestMethod] public void Tilde_StaticNameEncode() { SPListConnector.StaticNameEncode("Tilde~Word").Should().Be("Tilde_x007e_Word"); }
        [TestMethod] public void GraveAccent_StaticNameEncode() { SPListConnector.StaticNameEncode("Grave`Accent").Should().Be("Grave_x0060_Accent"); }
        [TestMethod] public void At_StaticNameEncode() { SPListConnector.StaticNameEncode("Word@Location").Should().Be("Word_x0040_Location"); }
        [TestMethod] public void Bang_StaticNameEncode() { SPListConnector.StaticNameEncode("Bang!").Should().Be("Bang_x0021_"); }
        [TestMethod] public void Pound_StaticNameEncode() { SPListConnector.StaticNameEncode("Pound#").Should().Be("Pound_x0023_"); }
        [TestMethod] public void Dollar_StaticNameEncode() { SPListConnector.StaticNameEncode("Dollar$").Should().Be("Dollar_x0024_"); }
        [TestMethod] public void Percent_StaticNameEncode() { SPListConnector.StaticNameEncode("Percent%").Should().Be("Percent_x0025_"); }
        [TestMethod] public void Carot_StaticNameEncode() { SPListConnector.StaticNameEncode("Carot^").Should().Be("Carot_x005e_"); }
        [TestMethod] public void Ampersand_StaticNameEncode() { SPListConnector.StaticNameEncode("Amper&sand").Should().Be("Amper_x0026_sand"); }
        [TestMethod] public void Asterisk_StaticNameEncode() { SPListConnector.StaticNameEncode("Asterisk*").Should().Be("Asterisk_x002a_"); }
        [TestMethod] public void Plus_StaticNameEncode() { SPListConnector.StaticNameEncode("Plus+").Should().Be("Plus_x002b_"); }
        [TestMethod] public void Equals_StaticNameEncode() { SPListConnector.StaticNameEncode("Equals=").Should().Be("Equals_x003d_"); }
        
        [TestMethod] public void ParenLeft_StaticNameEncode() { SPListConnector.StaticNameEncode("Paren(Left").Should().Be("Paren_x0028_Left"); }
        [TestMethod] public void ParenRight_StaticNameEncode() { SPListConnector.StaticNameEncode("Paren)Right").Should().Be("Paren_x0029_Right"); }
        [TestMethod] public void CompareGreater_StaticNameEncode() { SPListConnector.StaticNameEncode("Compare>To").Should().Be("Compare_x003e_To"); }
        [TestMethod] public void CompareLess_StaticNameEncode() { SPListConnector.StaticNameEncode("Compare<To").Should().Be("Compare_x003c_To"); }
        [TestMethod] public void BraceLeft_StaticNameEncode() { SPListConnector.StaticNameEncode("Brace{Left").Should().Be("Brace_x007b_Left"); }
        [TestMethod] public void BraceRight_StaticNameEncode() { SPListConnector.StaticNameEncode("Brace}Right").Should().Be("Brace_x007d_Right"); }

        [TestMethod] public void Comma_StaticNameEncode() { SPListConnector.StaticNameEncode("Comma,Word").Should().Be("Comma_x002c_Word"); }
        [TestMethod] public void Period_StaticNameEncode() { SPListConnector.StaticNameEncode("Period.").Should().Be("Period_x002e_"); }
        
        [TestMethod] public void SlashFwd_StaticNameEncode() { SPListConnector.StaticNameEncode("Slash/Fwd").Should().Be("Slash_x002f_Fwd"); }
        [TestMethod] public void SlashBack_StaticNameEncode() { SPListConnector.StaticNameEncode(@"Slash\Back").Should().Be("Slash_x005c_Back"); }
        [TestMethod] public void Pipe_StaticNameEncode() { SPListConnector.StaticNameEncode("Pipe|").Should().Be("Pipe_x007c_"); }

        [TestMethod] public void Question_StaticNameEncode() { SPListConnector.StaticNameEncode("Question?").Should().Be("Question_x003f_"); }

        [TestMethod] public void Colon_StaticNameEncode() { SPListConnector.StaticNameEncode("Colon:Word").Should().Be("Colon_x003a_Word"); }
        [TestMethod] public void ColonSemi_StaticNameEncode() { SPListConnector.StaticNameEncode("Colon;Semi").Should().Be("Colon_x003b_Semi"); }

        [TestMethod] public void Apostrophe_StaticNameEncode() { SPListConnector.StaticNameEncode("Apostrophe's").Should().Be("Apostrophe_x0027_s"); }
        [TestMethod] public void Quote_StaticNameEncode() { SPListConnector.StaticNameEncode("Quote\"").Should().Be("Quote_x0022_"); }

    }
}
